import httpRequest from '@/utils/hqqtRequest'
import type { MenuDataList } from './type'

enum API {
    // 获取菜单数据
    MENU_PERMISSION = '/admin/acl/permission',
    // 添加菜单
    ADD_MENU = '/admin/acl/permission/save',
    // 更新菜单
    UPDATE_MENU = '/admin/acl/permission/update',
    // 删除菜单
    DELETE_MENU = '/admin/acl/permission/remove/'
}

export const getMentPermissionAPI = () => httpRequest<any, MenuDataList>({ url: API.MENU_PERMISSION })

export const handleMenuDataAPI = (data: any) => {
    if (data.id) {
        return httpRequest({ url: API.UPDATE_MENU, method: 'PUT', data })
    } else {
        return httpRequest({ url: API.ADD_MENU, method: 'POST', data })
    }
}

export const deleteMenuAPI = (id: number | string) => httpRequest<any, any>({ url: API.DELETE_MENU + id, method: 'DELETE' })
